package com.tonicgb.api.front.controller;

import com.tonicgb.api.front.request.RegisterThirdUserRequest;
import com.tonicgb.api.front.request.WechatBindPhoneRequest;
import com.tonicgb.service.UserCenterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhaiyujin
 * @date 2021-10-04 22:53:58
 * @说明 微信 前端控制器
 */
@RestController
@RequestMapping("${frontPath}/wechat")
@Api(value = "微信相关接口",tags = "微信 -- 开放平台")
public class WeChatController {

    @Autowired
    private UserCenterService userCenterService;

    @ApiOperation(value = "微信登录小程序授权登录")
    @RequestMapping(value = "/authorize/program/login",method = RequestMethod.POST)
    public Object programLoginByCode(@RequestParam String code, @RequestBody @Validated RegisterThirdUserRequest request){

        return userCenterService.weChatAuthorizeProgramLogin(code,request);
    }

    @ApiOperation(value = "微信小程序绑定手机号")
    @PostMapping(value="/authorize/program/bindPhone")
    public Object bindPhone(@RequestBody @Validated WechatBindPhoneRequest wechatBindPhoneRequest){

        return userCenterService.weChatAuthorizeBindPhone(wechatBindPhoneRequest);
    }



}
